/*
 * @descripttion:
 * @author: cp
 * @Date: 2021-04-25 23:38:33
 */
const router = require('koa-router')();

// 路由前缀
router.prefix('/users');

router.get('/', async (ctx, next) => {
  ctx.body = 'this is a users response!';
});

router.get('/bar', async (ctx, next) => {
  ctx.body = 'this is a users/bar response';
});

router.get('/list', async (ctx, next) => {
  ctx.body = {
    code: 0,
    data: [1, 2, 3, 4, 5],
  };
});

router.post('/login', async (ctx, next) => {
  const { userName, password } = ctx.request.body;
  ctx.body = {
    userName,
    password,
  };
});

module.exports = router;
